package com.shop2cn.iapi.agentproducts.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.CheckPriceLimitBean;
import com.shop2cn.iapi.agentproducts.parameter.ProductDetailsDto;
import com.shop2cn.iapi.agentproducts.parameter.UpdatePriceDto;
import com.shop2cn.iapi.agentproducts.service.CheckPriceLimitCall;
import com.ymatou.iapi.godmch.parameter.setShareTypeBean;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
/**
*更改商户风控价格回调-检查价格超出的商品下架Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_CheckPriceLimit{
	private static CheckPriceLimitBean checkpricelimitBean;
	private static CheckPriceLimitCall checkpricelimitCall;
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("更改商户风控价格回调-检查价格超出的商品下架Test");
	}

	@Before
	public void caseUp() {
		checkpricelimitBean=new CheckPriceLimitBean();
		checkpricelimitCall=new CheckPriceLimitCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(checkpricelimitCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CheckPriceLimit_001() {
		Logger.start(true,"发布大于一万商品，然后修改限制，商品强制下架");
		try {
			int vipRootUserId= GodmchManageCallService.CreateSellerMch();
			//修改限制为20000
			setShareTypeBean initsetShareTypeV2 = GodmchManageCallService.initsetShareTypeV2(vipRootUserId);
			GodmchManageCallService.setShareTypeV2Call(initsetShareTypeV2);
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,"a",false);
			addAgentProductBean.setCurrency("CNY");
			addAgentProductBean.getCatalogList().get(0).setDirectPrice(10001.00);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Logger.verifyEquals(1, AddAgentProductCallService.selectProductDetails(vipRootUserId, productId).getStatus(), "验证商品状态--上架");
			//修改限制为10000
			initsetShareTypeV2 = GodmchManageCallService.initsetShareTypeV2(vipRootUserId);
			initsetShareTypeV2.setProductRiskAmount(new BigDecimal(10000));
			GodmchManageCallService.setShareTypeV2Call(initsetShareTypeV2);
			Logger.verifyEquals(2, AddAgentProductCallService.selectProductDetails(vipRootUserId, productId).getStatus(), "验证商品状态--上架");
			checkpricelimitBean.setUserId(vipRootUserId);
			checkpricelimitCall.setData(checkpricelimitBean);
			checkpricelimitCall.callService();			
			Logger.verifyEquals(2, AddAgentProductCallService.selectProductDetails(vipRootUserId, productId).getStatus(), "验证商品状态--下架");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}